package org.stvd.repository.logs.impl;

import java.util.Date;

import org.springframework.stereotype.Repository;
import org.stvd.core.dto.QueryResult;
import org.stvd.entities.logs.SysLoginInfo;
import org.stvd.repository.base.impl.BaseDaoImpl;
import org.stvd.repository.logs.SysLoginInfoDao;

/**
 * @Title: SysLoginInfoDaoImpl
 * @Description: 系统登录日志数据层接口实现类
 * @author houzx
 * @date 2020年9月2日
 */
@Repository("SysLoginInfoDao")
public class SysLoginInfoDaoImpl extends BaseDaoImpl<SysLoginInfo> implements SysLoginInfoDao{

    @Override
    public QueryResult<SysLoginInfo> queryLginInfoResult(int start, int limit,
        String userName, String status, String ipaddr, Date queryStartDate, Date queryEndDate) {
        String hql = "FROM SysLoginInfo WHERE userName Like ?0"
                + " AND (status = ?1 OR '' = ?1 )"
                + " AND (ipaddr = ?2 OR '' = ?2)"
                + " AND (loginTime >= ?3 OR ?3 is null)"
                + " AND (loginTime < ?4 OR ?4 is null)"
                + " ORDER BY loginTime DESC";
        return getQueryResultByHQL(start, limit, hql, "%"+userName+"%", status, ipaddr, queryStartDate, queryEndDate);
    }

}
